{% extends 'IcsocUIBundle::page.html.twig' %}
{% from 'IcsocUIBundle:Macro:grid.html.twig' import gridWidth,gridNav,gridConfig,gridKeyword %}
{% block stylesheet %}
    {{ parent() }}
    {% stylesheets
    '@jqgird_css'
    '@gritter_css'
    filter='cssrewrite' filter='uglifycss'
    %}
    <link rel="stylesheet" href="{{ asset_url }}" />
    {% endstylesheets %}
{% endblock %}

{% block content %}
    <table id="grid-table"></table>
    <div id="grid-pager"></div>
{% endblock %}
{% block footer %}
    {% javascripts
    '@jqgird_js'
    '@gritter_js'
    '@common_js'
    filter='uglifyjs'
    %}
    <script src="{{ asset_url }}"></script>
    {% endjavascripts %}
    <script type="text/javascript">
        jQuery(function($) {
            var height = $(document).height() - 200;
            {{ gridWidth() }}
            jQuery(grid_selector).jqGrid({
                caption: "{{ item.caption|trans({'%report_type%': item.report_type, '%start_date%': item.start_date, '%end_date%': item.end_date}) }}",
                url: "{{ path(item.url) }}",
                hidegrid:false,
                postData: {param: '{{ param }}'},
                mtype: 'POST',
                datatype: "json",
                colModel:[
                    {% for itemTitle in item.title %}
                    {% if itemTitle.sortable == '1' %}
                    {name: '{{ itemTitle.field }}', index: '{{ itemTitle.field }}', label: '{{ itemTitle.text|trans }}', frozen: true, width: '{{ itemTitle.width }}', align: 'center', sortable: true, fixed:true},
                    {% else %}
                    {name: '{{ itemTitle.field }}', index: '{{ itemTitle.field }}', label: '{{ itemTitle.text|trans }}', frozen: true, width: '{{ itemTitle.width }}', align: 'center', sortable: false, fixed:true},
                    {% endif %}
                    {% endfor %}
                ],
                {{ gridConfig(true) }}
                height: height,
                rownumWidth: 40,
                viewrecords: true, //定义是否要显示总记录数
                rowNum: -1,  //默认每页显示多少条数据
                //rowList: [20,30,50,100],
                sortname:"{{ item.sortname }}",
                sortorder:"{{ item.sortorder }}",
                multiselect: false,
                rownumbers: true,
                footerrow:true,
                userDataOnFooter:true
            });
            {{ gridNav(false,false,false,false,true,false) }}
            jQuery(grid_selector).navButtonAdd(
                    pager_selector,
                    {
                        caption:'{{ 'Export Csv'|trans }}',
                        buttonicon:'ace-icon fa fa-file-excel-o  primary',
                        onClickButton:function() {
                            location.href = "{{ path(item.url, {'export': 'csv','sidx' : item.sortname, 'param': param, 'type': item.type})|raw }}";
                        }
                    }
            ).navButtonAdd(
                    pager_selector,
                    {
                        caption:'{{ 'Export Excel'|trans }}',
                        buttonicon:'ace-icon fa fa-file-excel-o  primary',
                        onClickButton:function() {
                            location.href = "{{ path(item.url, {'export': 'excel','sidx' : item.sortname, 'param': param, 'type': item.type})|raw }}";
                        }
                    }
            ).navButtonAdd(
                    pager_selector,
                    {
                        caption:'{{ 'Go Back'|trans }}',
                        buttonicon:'ace-icon fa fa-reply  primary',
                        onClickButton:function() {
                            history.back()
                        }
                    }
            );
        });
    </script>
{% endblock %}